package com.andy.infrastructure.utils;

import java.util.Calendar;
import java.util.Date;

public class DateUtil {

    /**
     * 加天
     * @param date
     * @param days
     * @return
     */
    public static Date addDay(Date date, int days){
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.add(Calendar.DAY_OF_MONTH, days);// +n天

        return c.getTime();
    }

    /**
     * 加月
     * @param date
     * @param months
     * @return
     */
    public static Date addMonth(Date date,int months){
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.add(Calendar.MONTH, months);// +n月

        return c.getTime();
    }

    /**
     * 加年
     * @param date
     * @param years
     * @return
     */
    public static Date addYear(Date date,int years){
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.add(Calendar.YEAR, years);// +n年

        return c.getTime();
    }

    /**
     * 加分钟
     * @param date
     * @param minutes
     * @return
     */
    public static Date addMinute(Date date,int minutes){
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.add(Calendar.MINUTE, minutes);// +n分钟

        return c.getTime();
    }

}
